package com.dimples.dd.xxl.job.plus.controller;

import com.xxl.job.core.biz.ExecutorBiz;
import com.xxl.job.core.biz.model.*;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 执行器接受命令控制器，代替netty
 *
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/10/18
 */
@RestController
@RequiredArgsConstructor
public class ExecutorController {

    private final ExecutorBiz executorBiz;

    @PostMapping("/beat")
    public ReturnT<String> beat() {
        return executorBiz.beat();
    }

    @PostMapping("/idleBeat")
    public ReturnT<String> idleBeat(@RequestBody IdleBeatParam idleBeatParam) {
        return executorBiz.idleBeat(idleBeatParam);
    }

    @PostMapping("/run")
    public ReturnT<String> run(@RequestBody TriggerParam triggerParam) {
        return executorBiz.run(triggerParam);
    }

    @PostMapping("/kill")
    public ReturnT<String> kill(@RequestBody KillParam killParam) {
        return executorBiz.kill(killParam);
    }

    @PostMapping("/log")
    public ReturnT<LogResult> log(@RequestBody LogParam logParam) {
        return executorBiz.log(logParam);
    }
}
